UPDATE `${updateTableName}` AS t
SET DATA_STATE_ID = (SELECT s.id FROM c1_dictionary s WHERE s.`TYPE_CODE` = 'DATA_STATE_TYPE' AND s.`CODE` = 'activity')
WHERE NOT EXISTS(SELECT 1 FROM c1_dictionary e WHERE e.id = t.`DATA_STATE_ID`)
OR (t.`DATA_STATE_ID` IS NULL OR t.`DATA_STATE_ID` = '')
